<template>
  <div>
    <div class="huize_information">
      <div class="centre">
        <div class="information_top">
          <div></div>
          <div></div>
        </div>
        <div class="information_buttom">
          <h3>高考资讯</h3>
          <div class="top_header">
            <ul>
              <li v-for="(item,index) in tabsParam" @click="toggleTabs(index)" :key="index">{{item}}</li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <transition name="fade">
      <div class="information_content centre">
        <ul>
          <router-link
            :to="{
        name:'/AdvisoryDetails',
        params:{
          id : List.id
        }      
      }"
            v-for=" List  in contentList"
            :key="List.id"
            tag="li"
          >
            <div class="content_left">
              <h4>{{List.title}}</h4>
              <div class="content">{{List.content}}</div>
              <div class="tyle_item">
                <div class="tyle">
                  #{{types == "0" ? "热门推荐"
                  : types == "1" ? "独家解析"
                  : types == "2" ? "资讯头条"
                  : types == "3" ? "报考指南"
                  : types == "4" ? "报考经验"
                  : types == "5" ? "政策解读"
                  :" "}}
                </div>
                <div class="item">{{List.createTime}}</div>
              </div>
            </div>
            <div class="content_right">
              <img :src="List.picOne" alt />
            </div>
          </router-link>
        </ul>

        <h2 @click="page">查看更多</h2>
      </div>
    </transition>
  </div>
</template>
<script>
import Content from "./content";
export default {
  name: "Information",
  data() {
    return {
      tabsParam: [
        "热门推荐",
        "独家解析",
        "资讯头条",
        "报考指南",
        "报考经验",
        "政策解读"
      ],
      types: "0",
      pageSizes: 0,
      contentList: [],
      pageNows: 0
    };
  },
  components: {
    Content
  },
  beforeCreate() {
    this.$nextTick(() => {
      var types = this.types;
      this.getList(types);
    });
  },
  methods: {
    //切换tab项
    toggleTabs(index) {
      this.types = index;
      let pageNows = this.pageNows;

      var types = this.types;
      this.$ajax({
        method: "post",
        url: "/api/piccontent/list",
        data: {
          pageNow: 1,
          pageSize: 3,
          type: types
        },

        success: res => {
          if (res.data.code == 0) {
            this.contentList = res.data.data.list;
          } else {
          }
        }
      });
    },
    getList(types) {
      let pageNows = this.pageNows;
      var types = this.types;
      this.$ajax({
        method: "post",
        url: "/api/piccontent/list",
        data: {
          pageNow: 1,
          pageSize: 3 + pageNows,
          type: types
        },

        success: res => {
          if (res.data.code == 0) {
            this.contentList = res.data.data.list;
          } else {
          }
        }
      });
    },
    page() {
      var types = this.types;
      this.pageNows += 10;
      let pageNows = this.pageNows;

      this.$ajax({
        method: "post",
        url: "/api/piccontent/list",
        data: {
          pageNow: 1,
          pageSize: 3 + pageNows,
          type: types
        },

        success: res => {
          if (res.data.code == 0) {
            this.contentList = res.data.data.list;
          }
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}

//bounce(动画)
.bounce-enter-active {
  animation: bounce-in 0.5s;
}
.bounce-leave-active {
  animation: bounce-in 0.5s reverse;
}
@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(1);
  }
}

.information_top {
  padding: 46px 0;

  display: flex;
  justify-content: space-between;
  div {
    width: 580px;
    height: 192px;
    background: #f6f6f6;
    border-radius: 6px;
  }
}
.information_buttom {
  padding-bottom: 20px;
  h3 {
    margin-bottom: 36px;
  }

  .top_header {
    margin-bottom: 26px;

    ul {
      display: flex;
      li {
        cursor: pointer;
        margin-right: 62px;
        color: #959595;
      }
      li:hover {
        color: #414141;
      }
    }
  }
}
.information_content {
  h2 {
    text-align: center;
    padding: 32px 0;
    color: #959595;
    font-size: 18px;
    cursor: pointer;
  }
  ul {
    li {
      background: #f0f0f0;
      display: flex;
      justify-content: space-between;
      padding: 28px 72px;
      margin-bottom: 24px;
      border-radius: 3px;
      .content_left {
        margin-top: 12px;
        h4 {
          color: #414141;
          line-height: 42px;
          font-size: 20px;
        }
        .content {
          width: 830px;
          color: #757575;
          font-size: 14px;
          line-height: 20px;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 3;
          overflow: hidden;
        }
        .tyle_item {
          display: flex;
          justify-content: space-between;
          width: 318px;
          padding: 40px 0;
          font-size: 12px;
          color: #8a8a8a;
        }
      }
      .content_right {
        img {
          width: 172px;
          height: 172px;
          border-radius: 6px;
        }
      }
    }
  }
}
</style>